using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace WebDauGia.Domain.Models.Mapping
{
    public class LoaiSanPhamMap : EntityTypeConfiguration<LoaiSanPham>
    {
        public LoaiSanPhamMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            this.Property(t => t.ten)
                .IsRequired();
            //this.Property(t => t.iddanhmuc)
             //   .IsRequired();
            // Table & Column Mappings
            this.ToTable("LoaiSanPhams");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.ten).HasColumnName("ten");
            this.Property(t => t.mota).HasColumnName("mota");
            this.Property(t => t.iddanhmuc).HasColumnName("iddanhmuc");
            this.Property(t => t.active).HasColumnName("active");

            // Relationships
            this.HasOptional(t => t.DanhMucSanPham)
                .WithMany(t => t.LoaiSanPhams)
                .HasForeignKey(d => d.iddanhmuc);

        }
    }
}
